Skip to content

CMake: Fix missing librt target #5056

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed

Conversation

etcwilde
Copy link
Contributor

@etcwilde etcwilde commented Aug 7, 2024

When building the static SDK, dispatch is built as a static archive, so its dependency on librt is exposed as part of its link interface. This shows up in the dispatchConfig.cmake file imported by find_package(dispatch CONFIG).

CMake Error at build/x86_64/dispatch/cmake/modules/dispatchExports.cmake:71 (set_target_properties):
  The link interface of target "dispatch" contains:

    RT::rt

  but the target was not found.  Possible reasons include:

    * There is a typo in the target name.
    * A find_package call is missing for an IMPORTED target.
    * An ALIAS target is missing.

It would be great if the dispatch config could include that target to ensure that everyone is using the same librt, it does not, so we have to find and include it ourselves.

When building the static SDK, dispatch is built as a static archive, so
it's dependency on librt is exposed as part of its link interface.
This shows up in the `dispatchConfig.cmake` file imported by
`find_package(dispatch CONFIG)`.

```
CMake Error at build/x86_64/dispatch/cmake/modules/dispatchExports.cmake:71 (set_target_properties):
  The link interface of target "dispatch" contains:

    RT::rt

  but the target was not found.  Possible reasons include:

    * There is a typo in the target name.
    * A find_package call is missing for an IMPORTED target.
    * An ALIAS target is missing.
```

It would be great if the dispatch config could include that target to
ensure that everyone is using the same librt, it does not, so we have to
find and include it ourselves.
@etcwilde
Copy link
Contributor Author

etcwilde commented Aug 7, 2024

@swift-ci please test

@etcwilde
Copy link
Contributor Author

etcwilde commented Aug 7, 2024

(There are more failures in the static SDK builds, figured I'd put this one up for now.)

@@ -93,6 +93,7 @@ if(NOT SwiftFoundation_MODULE_TRIPLE)
endif()

# System dependencies
find_package(LibRT)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For my context, is there a reason that's preventing us from fixing this on the dispatch side instead of applying a workaround to Foundation (and presumably any other project that imports dispatch via CMake in the toolchain)? Is there a way we can just add this to the exported config for dispatch?

@etcwilde
Copy link
Contributor Author

This will be fixed as part of #5069.
Closing this smaller PR.

@etcwilde etcwilde closed this Aug 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants